/**
 * 
 */
package exp.social.graph.rest;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;

import exp.social.graph.business.User;

/**
 * @author Volodya Gavrysh
 * 
 */
@Path("/users/{userid}")
public class UserResource {
	@GET
	@Produces("application/json")
	public String getJSON(@PathParam("userid") Integer userId) {
		User user = User.getById(userId);
		if (user != null) {
			return user.toJSON();
		} else {
			throw new WebApplicationException(404);
		}
	}

	@DELETE
	public void deleteUser(@PathParam("userid") Integer userId) {
		User.remove(userId);
	}
}
